package cn.my.framework.common.repo;

import cn.my.framework.common.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by zhangl_lc on 2017/7/6.
 */
public interface RoleRepo extends JpaRepository<Role,Integer> {

    //@Query("select r from Role r inner join UserRole ur on ur.roleCode = r.code where ur.userCode = ?1")
    @Query(value = "select r.* from role r inner join user_role ur on ur.role_code = r.code where ur.user_code = ?1",nativeQuery = true)
    List<Role> selectByUserCode(String userCode);
}
